package com.jdragon.tljrobot.client.utils;

import lombok.extern.log4j.Log4j2;

import java.util.Properties;

@Log4j2
public class SystemUtil {
    private static String systemName;
    private static String systemVersion;
    private static final Object lock = new Object();

    public static String getSystemName() {
        Properties props = System.getProperties();
        if (systemName == null) {
            systemName = props.getProperty("os.name");
            systemVersion = props.getProperty("os.version");
            log.debug("操作系统的名称：" + systemName);
            log.debug("操作系统的版本：" + systemVersion);
        }

        return systemName;
    }

    public static boolean isLinux() {
        String systemName = getSystemName();
        return systemName != null && systemName.toLowerCase().contains("linux");
    }

    public static boolean isWindows() {
        String systemName = getSystemName();
        return systemName != null && systemName.startsWith("Windows");
    }

    public static boolean isMac() {
        String systemName = getSystemName();
        return systemName != null && systemName.startsWith("Mac");
    }
}
